﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DeploymentMaxLib.Actions
{
    public class ActionXML : ActionBase
    {
        /// <summary>
        /// 
        /// </summary>
        public override string LongName
        {
            get { return Common.Constants.LongName; }
        }

        public override string Description
        {
            get { return Common.Constants.Description; }
        }

        public override ActionResponse Execute(ActionRequest pActionRequest)
        {

            base.Result = Validate(pActionRequest);

            if (!base.Result.HasErrorOrCritical())
            {
                var tExecutionType = pActionRequest.ExecutionType.ToEnum<Common.ExecutionType>();
                switch (tExecutionType)
                {
                    case Common.ExecutionType.SetElementInnerXmlByXPath:
                        {

                        } break;
                }
            }


            return pActionRequest.GetResponse(this);
        }

        public void SetElementInnerXmlByXPath(string pFileName, string pXPath, string pInnerXml)
        {


            try
            {

                var tXmlDocument = new System.Xml.XmlDocument();
                tXmlDocument.Load(pFileName);
                //tXmlDocument.SetElementValueByXPath(
            }
            catch (Exception exc)
            {
                base.Result.AddResult(exc);
            }


        }

        public static class Common
        {
            public enum ExecutionType
            {
                None = 0,
                SetElementInnerXmlByXPath = 1,

            }

            public static class Constants
            {
                public const string LongName = "";
                public const string Description = "";
            }
        }

        public override ActionResult Validate(ActionRequest pRequest)
        {
            throw new NotImplementedException();
        }

    }
}
